package com.utils.db;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

/**
 * 行数据转对象
 *
 * @author: dingjiejun
 * @version: 1.0
 * @date: 2017/3/23
 */
public class BeanRowMapper<T> implements RowMapper<T> {

    /**
     * 转换器
     */
    private final ResultSetToBeanProcess resultSetToBeanProcess = new ResultSetToBeanProcess();

    /**
     * 目标类
     */
    private Class<T> clz = null;

  

    /**
     * 是否基本类型
     */
    private boolean isPrimitive = false;


    public BeanRowMapper(Class<T> clz) {
        this.clz = clz;
        this.isPrimitive = ClassUtils.isPrimitiveOrWrapper(clz);
    }

    @Override
	public T mapRow(ResultSet rs, int pos) throws SQLException {
        return resultSetToBeanProcess.toPrimitive(rs, clz);
    }

}

